/*******************************************************************************
* @file    fins_test.c
* @author  Fins
* @brief   
* @time    2020-11-19 18:48:49 Thursday
* @codeing UTF-8
* @license
*     Copyright 2020 Fins
*
*     Licensed under the Apache License, Version 2.0 (the "License");
*     you may not use this file except in compliance with the License.
*     You may obtain a copy of the License at
*
*         http://www.apache.org/licenses/LICENSE-2.0
*
*     Unless required by applicable law or agreed to in writing, software
*     distributed under the License is distributed on an "AS IS" BASIS,
*     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*     See the License for the specific language governing permissions and
*     limitations under the License.
* @verbatim
================================================================================
                        ##### xxxxxxxxxxxxxxxxxxxxxxx #####
================================================================================
* @endverbatim
* @attention
*******************************************************************************/



/* Includes start *************************************************************/
/*     Lib files ****************************** */

/*     User files ***************************** */
#include "..\inc\fins_test.h"

/* Includes end ***************************************************************/

/* Define start ***************************************************************/



/* Define end *****************************************************************/

/* Typedef start **************************************************************/



/* Typedef end ****************************************************************/

/* Global variable start ******************************************************/

static fuint32 failCount = 0;
static fuint32 passCount = 0;
static fuint32 testCount = 0;
static fchar* unitName = F_NULL;



/* Global Variable end ********************************************************/

/* Static function declaration start ******************************************/

/**
  * @brief      Test ture
  * @param[in]  expr: Expr result
  * @param[in]  line: Line number
  * @retval     None
  */
void FtTrue(const fchar* experStr, fbool exprRes, fsint32 line)
{
    testCount++;
    if (exprRes == F_TRUE)
    {
        passCount++;
        __FT_OUT_SET(__FT_CLR_GREEN);
        __FT_FORMENT_PRINTF(
            __FT_RES_PASS_STR,
            __FT_ATTR_UNIT_STR,
            "(%s) %s%d",
            experStr,
            __FT_AT_STR,
            line);
        __FT_OUT_SET(__FT_CLR_DEF);
    }
    else
    {
        failCount++;
        __FT_OUT_SET(__FT_CLR_RED);
        __FT_FORMENT_PRINTF(
            __FT_RES_FAIL_STR,
            __FT_ATTR_UNIT_STR,
            "(%s) %s%d",
            experStr,
            __FT_AT_STR,
            line);
        __FT_OUT_SET(__FT_CLR_DEF);

    }
}

/**
  * @brief      Test false
  * @param[in]  expr: Expr result
  * @param[in]  line: Line number
  * @retval     None
  */
void FtFalse(const fchar* experStr,fbool exprRes, fsint32 line)
{
    testCount++;
    if (exprRes == F_FALSE)
    {
        passCount++;
        __FT_OUT_SET(__FT_CLR_GREEN);
        __FT_FORMENT_PRINTF(
            __FT_RES_PASS_STR,
            __FT_ATTR_UNIT_STR,
            "(%s) %s%d",
            experStr,
            __FT_AT_STR,
            line);
        __FT_OUT_SET(__FT_CLR_DEF);
    }
    else
    {
        failCount++;
        __FT_OUT_SET(__FT_CLR_RED);
        __FT_FORMENT_PRINTF(
            __FT_RES_FAIL_STR,
            __FT_ATTR_UNIT_STR,
            "(%s) %s%d",
            experStr,
            __FT_AT_STR,
            line);
        __FT_OUT_SET(__FT_CLR_DEF);
    }
}

/**
  * @brief      Test equal
  * @param[in]  data1: Data 1
  * @param[in]  data2: Data 2
  * @param[in]  line: Line number
  * @retval     None
  */
void FtEq(
    const fchar* data1Str, fsint32 data1,
    const fchar* data2Str, fsint32 data2, 
    fsint32 line)
{
    testCount++;
    if (data1 == data2)
    {
        passCount++;
        __FT_OUT_SET(__FT_CLR_GREEN);
        __FT_FORMENT_PRINTF(
            __FT_RES_PASS_STR,
            __FT_ATTR_UNIT_STR,
            "(<%s>:%d == <%s>:%d) %s%d",
            data1Str, data1,
            data2Str, data2,
            __FT_AT_STR,
            line);
        __FT_OUT_SET(__FT_CLR_DEF);
    }
    else
    {
        failCount++;
        __FT_OUT_SET(__FT_CLR_RED);
        __FT_FORMENT_PRINTF(
            __FT_RES_FAIL_STR,
            __FT_ATTR_UNIT_STR,
            "(<%s>:%d != <%s>:%d) %s%d",
            data1Str, data1,
            data2Str, data2,
            __FT_AT_STR,
            line);
        __FT_OUT_SET(__FT_CLR_DEF);
    }
}

/* Static function declaration end ********************************************/

/* function start *************************************************************/



/* function end ***************************************************************/

////////////////////////////////- END OF FILE  -////////////////////////////////
